import request from "@/utils/request";
import { PlatformForm } from "./types";
import { AxiosPromise } from "axios";
import {PlatformQuery} from "@/api/platform/types";

/**
 * 平台分页数据
 *
 * @param queryParams
 */
export function getPlatformPage(
	queryParams: PlatformQuery
): AxiosPromise<PageResult<[]>> {
	return request({
		url: '/api/v1/platform/page',
		method: 'get',
		params: queryParams
	});
}

/**
 * 获取平台表单数据
 *
 * @param queryParams
 */
export function getPlatformForm(platformId: number): AxiosPromise<PlatformForm> {
	return request({
		url: '/api/v1/platform/' + platformId + '/form',
		method: 'get'
	});
}

/**
 * 获取平台列表
 *
 */
export function getPlatformList(): AxiosPromise<[]> {
	return request({
		url: '/api/v1/platform/list',
		method: 'get'
	});
}

/**
 * 保存平台
 *
 * @param data
 */
export function savePlatform(data: PlatformForm) {
  return request({
    url: "/api/v1/platform",
    method: "post",
    data: data,
  });
}

/**
 * 删除平台
 *
 * @param ids
 */
export function deletePlatforms(ids: string) {
	return request({
		url: '/api/v1/platform/' + ids,
		method: 'delete'
	});
}
